import { Select } from 'antd';
import React from 'react';
import { defaultFormatResult, useRequest } from '@/hooks';
import { getNewsType } from '@/services/setting/newsManage';

const TagListInput = React.forwardRef((props, ref) => {
    const { onChange, value } = props;
    const { data: newsType, loading: newsTypeLoading } = useRequest(getNewsType, {
        cacheKey: 'news-types',
        ...defaultFormatResult
    });

    return (
        <Select ref={ref} value={value} loading={newsTypeLoading} onChange={onChange} {...props}>
            {newsType && newsType.map(item => <Select.Option value={item.value}>{item.name}</Select.Option>)}
        </Select>
    );
});

export default TagListInput;
